<?php 
	include('inc/reuse/dbconfig.php');
	$title = "";
	$sql = "SELECT * FROM fix_main_products_type";
	$rsd = mysql_query($sql);
	$layout="";
	//สินค้าย่อย แยกตามสินค้าหลัก
	$sub_layout="";
	//สินค้าย่อยทั้งหมด
	$sub_all ="";
	while($row = mysql_fetch_array($rsd)){
		$layout .= "<li>
					<a href=\"products.php?main_id=".$row['fix_main_products_type_id']."\">".$row['fix_main_products_type_name']."</a>";
		//echo $row['fix_main_products_type_name'];
		$sql = "SELECT * FROM fix_sub_products_type WHERE fix_main_products_type_id=".$row['fix_main_products_type_id'];
		$rsd2 = mysql_query($sql);
		$numOfRow = mysql_num_rows($rsd2);
		if($numOfRow  > 0)
		{			
			$sub_layout = "<ul>";
			while($row2 = mysql_fetch_array($rsd2)){
				
				$sub_layout .= "<li>
								<a href=\"products.php?main_id=".$row['fix_main_products_type_id']."&sub_id=".$row2['fix_sub_products_type_id']."\">".$row2['fix_sub_products_type_name']."</a>
							  </li>";

				$sub_all  .= "<li>
								<a href=\"products.php?main_id=".$row['fix_main_products_type_id']."&sub_id=".$row2['fix_sub_products_type_id']."\">".$row2['fix_sub_products_type_name']."</a>
							  </li>";
			}
			$sub_layout .= "</ul>";			
		}
		$layout .= $sub_layout;
		$layout .= "</li>";
	}
	echo "<li>
			<a href=\"products.php\">สินค้าทั้งหมด</a>".
		 "</li>".
		 $layout;
?>